﻿using Api.Application.Command.Report;
using Api.DTO;
using ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Api.Controllers
{
    /// <summary>
    /// 报表控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize]
    public class ReportController : ControllerBase
    {
        private readonly IMediator mediator;

        public ReportController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取汇总数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<LeaveSummaryDTO>>> GetLeaveSummary([FromQuery]GetLeaveSummaryCommand request)
        { 
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取明细数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<LeaveRecordDTO>>> GetLeaveDetail([FromQuery]GetLeaveDetailCommand request)
        {
            return await  mediator.Send(request);
        }
    }
}
